<?
class TemplateProduct{
    var $fieldsort = '';//Sắp xếp theo trường nào
    var $sort		= '';//Sắp xếp tăng hay giảm
    var $page		= 1;//Trang hiện tại
    var $page_size = 12;//Kích cỡ 1 trang hiển thị bao nhiêu kết quả
    public function product() {
        $slides = db_array('SELECT *
                        FROM products
                        WHERE pro_active = 1
                        ORDER BY pro_order
                        LIMIT '.($this->page - 1)*$this->page_size.' ,'.$this->page_size);
        return $slides;
    }  
    public function pro_total() {
        $arr = db_array('SELECT pro_id
                        FROM products
                        WHERE pro_active = 1
                        ');
        return count($arr);
    }    
    public function pro_detail($pro_id) {
        $arr = db_first('SELECT *
                        FROM products
                        WHERE pro_id ='.$pro_id);
        return $arr;
    }   
    public function pro_cat($pro_cat_id) {
        $arr = db_array('SELECT *
                        FROM products
                        WHERE pro_active = 1
                        AND pro_cat_id = '.$pro_cat_id.'
                        ORDER BY pro_order ASC, pro_id DESC
                        LIMIT '.($this->page - 1)*$this->page_size.' ,'.$this->page_size);
        return $arr;
    }
    public function pro_cat_id_inf($pro_cat_id) {
        $arr = db_first('SELECT *
                        FROM categories_multi
                        WHERE cat_type = "product"
                        AND cat_id = '.$pro_cat_id);
        return $arr;
    }
    public function pro_cat_total($pro_cat_id) {
        $arr = db_array('SELECT pro_id
                        FROM products
                        WHERE pro_active = 1
                        AND pro_cat_id ='.$pro_cat_id);
        return count($arr);
    }    
}
?>